﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>

    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <h3 style="text-align:center">增加客户</h3>
                    <h2>基本信息</h2>
                    <hr class="layui-border-green">
                    <table>
                        <tr>
                            <td>
                                <label class="layui-form-label">客户编号</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="clientsNo" name="clientsNo" placeholder="客户编号" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">客户名称</label>
                                    <div class="layui-input-inline layui-input-wrap">
                                        <input type="text" id="clientsName" name="clientsName" placeholder="客户名称" class="layui-input">
                                    </div>
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">客户区分</label>
                                    <div class="layui-input-block">
                                        <select id="clientsType" name="clientsType" lay-filter="aihao">

                                            <option value="公司">公司</option>
                                            <option value="个人">个人</option>

                                        </select>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">客户电话</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="clientsTell" name="clientsTell" placeholder="请输入联系方式" class="layui-input">
                                </div>
                            </td>
                        </tr>



                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">客户行业</label>
                                    <div class="layui-input-block">
                                        <select id="clientsWork" name="clientsWork" lay-filter="aihao">
                                            <option value="">请选择客户行业</option>
                                            <option value="IT互联网">IT互联网</option>
                                            <option value="制造业">制造业</option>
                                            <option value="服务业">服务业</option>

                                        </select>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">客户邮箱</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="clientsEmls" name="clientsEmls" class="layui-input">
                                </div>
                            </td>
                        </tr>


                        <td>
                            <label class="layui-form-label">客户地址</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="clientsAdds" name="clientsAdds" placeholder="客户地址" class="layui-input">
                            </div>
                        </td>



                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">所在城市</label>
                                    <div class="layui-input-block">
                                        <select id="clientsCity" name="clientsCity" lay-filter="aihao">
                                            <option value="">请选择所在城市</option>
                                            <option value="北京">北京</option>
                                            <option value="上海">上海</option>
                                            <option value="广州">广州</option>
                                            <option value="深圳">深圳</option>
                                            <option value="杭州">杭州</option>
                                            <option value="郑州">郑州</option>
                                            <option value="重庆">重庆</option>
                                            <option value="武汉">武汉</option>
                                            <option value="南京">南京</option>
                                        </select>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">所在国家</label>
                                <div class="layui-input-block">
                                    <select id="clientsUnid" name="clientsUnid" lay-filter="aihao">
                                        <option value="">请选择所在国家</option>
                                        <option value="中国">中国</option>
                                    </select>
                                </div>
                            </td>
                        </tr>


                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">客户分类</label>
                                    <div class="layui-input-block">
                                        <select id="clientsClie" name="clientsClie" lay-filter="aihao">
                                            <option value="-1">请选择客户分类</option>
                                            <option value="1">普通客户</option>
                                            <option value="2">VIP客户</option>
                                        </select>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">客户分类</label>
                                <div class="layui-input-block">
                                    <div class="layui-input-inline layui-input-wrap">
                                        <input type="text" id="clientsClie" name="clientsClie" placeholder="客户地址" class="layui-input">
                                    </div>
                                </div>
                            </td>
                        </tr>


                        <tr>
                            <td>
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-block">
                                    <select id="clientsSmar" name="clientsSmar" lay-filter="aihao">
                                        <option value="">请选择</option>
                                        <option value="有效">有效</option>
                                        <option value="无效">无效</option>
                                    </select>
                                </div>
                            </td>



                            <td>
                                <label class="layui-form-label">本公司标识</label>
                                <div class="layui-input-block">
                                    <select id="clientsTite" name="clientsTite" lay-filter="aihao">
                                        <option value="">请选择</option>
                                        <option value="1">是</option>
                                        <option value="2">否</option>
                                    </select>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <input type="button" class="layui-btn" lay-submit lay-filter="demo1" value="修改" />
                </div>
            </div>
        </div>
    </form>
</body>

</html>
<script>
    layui.use(function () {
        var form = layui.form;
        var layer = layui.layer;

        // 提交事件
        form.on('submit(demo1)', function (d) {
            var data = {

                clientsNo: $("#clientsNo").val(),
                clientsName: $("#clientsName").val(),
                clientsType: $("#clientsType").val(),
                clientsTell: $("#clientsTell").val(),
                clientsEmls: $("#clientsEmls").val(),
                clientsWork: $("#clientsWork").val(),
                clientsAdds: $("#clientsAdds").val(),
                clientsUnid: $("#clientsUnid").val(),
                clientsCity: $("#clientsCity").val(),
                clientsTite: $("#clientsTite").val(),
                clientsWork: $("#clientsWork").val(),
                clientsSmar: $("#clientsSmar").val(),
                clientsbiao: $("#clientsbiao").val(),

            };
            $.ajax({
                url:'@ViewBag.RBACWrite' + "/api/Client/addClients",
                type: 'post',
                data: JSON.stringify(data),
                dataType: "json",
                contentType: "application/json",

                success: res => {
                    if (res.code == 0) {
                        layer.msg('添加成功')
                         location.href = "/Clinets/ShowClients/"
                    }
                    else {
                        layer.msg('保存失败')
                    }
                }
            })
            return false; // 阻止默认 form 跳转
        });

    });




</script>